package com.world.rickcloudendpoint.service.net.handler;

import com.world.rickcloudendpoint.common.exception.NetMessageException;
import com.world.rickcloudendpoint.service.net.session.TcpNetSession;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * @description:  Tcp 连接通道处理器
 * @author: jlsong
 * @date: 2021/12/24 20:51:32
 * @version: 1.0
 */
@Log4j2
@Component
@ChannelHandler.Sharable
public abstract class AbstractNetMessageTcpServerHandler extends ChannelInboundHandlerAdapter {

    public abstract void addUpdateSession(TcpNetSession tcpNetSession);

    @Override
    public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
        super.channelRegistered(ctx);
    }

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        super.userEventTriggered(ctx, evt);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        super.exceptionCaught(ctx, cause);
    }

    @Override
    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
        super.channelUnregistered(ctx);
    }

    @Override
    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
        super.channelReadComplete(ctx);
    }

    private static void disconnect(Channel channel) throws NetMessageException{

    }
}
